how to install keepalived for nginx on centos7.2

install keepalived:

yum install kernel-devel -y
curl -LO https://www.keepalived.org/software/keepalived-2.2.0.tar.gz
tar zxvf keepalived-2.2.0.tar.gz
cd keepalived-2.2.0
mkdir -p /usr/local/keepalived
cp /usr/src/kernels/3.10.0-327.el7.x86_64/include/uapi/linux/memfd.h /usr/include/linux/
./configure --prefix=/usr/local/keepalived
make && make install

prepare configuration file:

! Configuration File for keepalived

global_defs {
   router_id master #slave
}
vrrp_script check_nginx {
        script "/usr/local/keepalived/check_nginx.sh"
        interval 2
}

vrrp_instance VI_1 {
    state MASTER #BACKUP
    interface eth0
    virtual_router_id 51
    advert_int 1
    priority 200 #100
    unicast_src_ip master_ip #slave_ip
    unicast_peer {
        slave_ip #master_ip
    }
    authentication {
        auth_type PASS
        auth_pass chenshi.net
    }
    track_script {
        check_nginx
    }
    virtual_ipaddress {
        virtual_ip
    }
}

cat /usr/local/keepalived/check_nginx.sh

#!/bin/bash
pidof nginx
if [ $? -ne 0 ];then
killall keepalived
fi